package com.lipy.dubboproduct.filter;

import com.alibaba.dubbo.common.Constants;
import com.alibaba.dubbo.common.extension.Activate;
import com.alibaba.dubbo.common.extension.SPI;
import com.alibaba.dubbo.rpc.*;
//@Activate(group = {Constants.CONSUMER})
public class IPFilter implements Filter {
    private boolean enabledIpWhite = true;

    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        if(!enabledIpWhite){
            System.out.println("IPFilter.invoke 白名单禁用");
            return invoker.invoke(invocation);
        }
        String remoteHost = RpcContext.getContext().getRemoteHost();
        System.out.println("IPFilter.invoke 访问的ip "+ remoteHost);

        return invoker.invoke(invocation);
//        return new RpcResult();
    }
}
